package rock.serialize;

import rock.common.annotation.SPI;

/**
 * 序列化接口
 */
@SPI
public interface Serializer {

    /**
     * 序列化
     * @param obj
     * @return
     */
    public byte[] serialize(Object obj) throws Exception;

    /**
     * 反序列化
     * @param bytes
     * @param clazz
     * @param <T>
     * @return
     */
    public <T> T deserialize(byte[] bytes, Class<T> clazz) throws Exception;
}
